<template>
	<view class="work-container">

		<!-- 轮播图 -->
		<swiper class="swiper-box" :circular="true" :autoplay="true" :indicator-dots="true">
			<swiper-item v-for="(item, index) in sceneList" :key="index">
				<view class="swiper-item" @click="clickBannerItem(item)">
					<image :src="imageList(item.notice_photo)" mode="aspectFill" :draggable="false" />
				</view>
			</swiper-item>
		</swiper>
		<!-- 宫格组件 -->
		<view class="grid">
			<uni-grid :column="4" :highlight="true" :showBorder="false">
				<uni-grid-item>
					<view class="grid-item-box" style="background-color: #fff;" @click="gotoAdvice">
						<uni-icons type="chat-filled" :size="45" color="#ff0000" />
						<text class="text">谏言</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view @click="payFee(user.userId)" class="grid-item-box" style="background-color: #fff;">
						<uni-icons type="wallet-filled" :size="45" color="#ff0000" />
						<text class="text">党费</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" style="background-color: #fff;" @click="gotoMsg">
						<uni-icons type="chatbubble-filled" :size="45" color="#ff0000" />
						<text class="text">消息</text>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<view class="grid-item-box" style="background-color: #fff;" @click="gotoMe">
						<uni-icons type="person-filled" :size="45" color="#ff0000" />
						<text class="text">我的</text>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>

		<!-- 通知 -->
		<view class="footer-top">
			<view v-for="(slide, i) in noticeList" :index="i" :key="i">
				<view  class="footer" @click="gotoDetails(slide)">
					<view class="footer-image"  >
					<image :src="imageList(slide.notice_photo)"></image>
				</view>
				<view class="footer-content">
					<view class="content-title">
						{{slide.noticeTitle}}
					</view>
					<view class="content-author">
						{{slide.createBy}}
					</view>
					<view >
						<mp-html class="content-body" :content="slide.noticeContent" />
					</view>
					<view class="date" :date="slide.createTime" format="MM/dd">
						{{slide.createTime}}
					</view>
				</view>	
				</view>
			
			</view>
		</view>
	</view> 
</template>

<script>
	import {
		getUser
	} from "@/api/home/home.js"
	import { getUserProfile } from "@/api/system/user"
	import currySwiper from "@/components/curry-swiper/curry-swiper.vue"
	import currySlide from "@/components/curry-swiper/curry-slide.vue"
	import {
		getCurrNotice,
		getCarousele
	} from "@/api/home/home.js"
	import mpHtml from '@/components/mp-html/mp-html'
	export default {
		components: {
			currySwiper,
			currySlide,
			mpHtml
		},
		data() {
			return {
				user: {},
				current: 0,
				swiperDotIndex: 0,
				sceneList: [],
				noticeList: []
			}
		},
		methods: {
			clickBannerItem(item) {
				 uni.navigateTo({
				 	url: '/pages/details/details?item='+encodeURIComponent(JSON.stringify(item))
				 })
			},
			// 谏言
			gotoAdvice() {
				uni.navigateTo({
					url: '/pages/advice/advice'
				})
			},
			//详情页
			gotoDetails(event) {
				uni.navigateTo({
					url: '/pages/details/details?item='+encodeURIComponent(JSON.stringify(event))
				})

			},
			//跳转消息
			gotoMsg() {
				uni.switchTab({
					url: '/pages/msg/msg'
				})

			},
			//跳转我的
			gotoMe() {
				uni.switchTab({
					url: '/pages/mine/index'
				})

			},
			payFee(userId){
				uni.navigateTo({
					url: '/pages/pay-due/pay-due?userId='+userId
				})
			},
			getUser() {
			  getUserProfile().then(response => {
			   this.user=response.data
			   
			  })
			}
		},
		created() {
		  
		}, 
		computed: {
			imageList() {
				return function(e){ 
					return e.split(",")[0]
				}
			}
		},
		onShow() {
			getUser().then(res=>{
					if(res.data.code=200){
					this.user=res.data	
					console.log("user",this.user);
				  getCarousele(res.data.userId).then(res=>{
						if (res.code == 200) {
						  this.sceneList = res.data;
						  console.log("图片",this.sceneList);
						}
					})
					}
					
				}),
				getUser().then(res=>{
						if(res.data.code=200){
						this.user=res.data	
					  getCurrNotice(res.data.userId).then(res=>{
							if (res.code == 200) {
									this.noticeList = res.data;
									console.log(this.noticeList+"()");
								}
						})
						}
						
					})
			// this.sceneList
			// getCarousele(this.user.userId).then(res => {
			// 		if (res.code == 200) {
			// 		  this.sceneList = res.data;
			// 		}
		 //    }),
				// getCurrNotice(this.user.userId).then(res => {
				// 	console.log(this.user.userId)
				// 	if (res.code == 200) {
				// 		this.noticeList = res.data;
				// 		console.log(this.noticeList+"()");
				// 	}
				// })
		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff;
		min-height: 100%;
		margin-top: 0rpx;
		height: auto;
	}

	view {
		font-size: 14px;
		line-height: inherit;
	}

	/* #endif */

	.text {
		text-align: center;
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.grid-item-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.uni-margin-wrap {
		width: 690rpx;
		width: 100%;
		;
	}

	.swiper {
		height: 400rpx;
	}

	.swiper-box {
		height: 400rpx;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #fff;
		height: 400rpx;
		line-height: 300rpx;
	}

	@media screen and (min-width: 500px) {
		.uni-swiper-dot-box {
			width: 400px;
			/* #ifndef APP-NVUE */
			margin: 0 auto;
			/* #endif */
			margin-top: 8px;
		}

		.image {
			width: 100%;
		}
	}

	.grid {
		margin: 10px;
	}

	.footer {
		margin: 10px;
		display: flex;
		justify-content: space-between;

		.footer-image {
			display: block;
			width: 450rpx;
			height: 250rpx;
			margin-right: 10rpx;

			image {
				width: 350rpx;
				height: 250rpx;
			}
		}

		.footer-content {
			display: flex;
			flex-direction: column;
		}
	}

	.content-title {
		color: black;
		font-weight: bold;
		font-size: 38rpx;
		margin-bottom: 16rpx;
		max-width: 310rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		
		white-space: nowrap;
	}

	.content-body {
		font-size: 15px;
		overflow: hidden;
		-webkit-line-clamp: 2;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		margin-bottom: 13px;
	}
	
	.content-author{
		font-size: 15px;
		overflow: hidden;
		-webkit-line-clamp: 2;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		margin-bottom: 3px;
	}
	
	.footer-top {
		display: flex;
		flex-direction: column;
	}
	.notice-content{
    display: block;  
    font-family: PingFangSC-Regular;  
        font-size: 14px;  
        color: #482929;  
        letter-spacing: 0;  
        line-height: 20px;  
        overflow:hidden;  
        text-overflow:ellipsis;  
        white-space: normal;  
        display:-webkit-box;  
        -webkit-box-orient:vertical;  
        -webkit-line-clamp:2;/*规定最多显示两行*/  
	}
</style>
